<?php

namespace App\Http\Controllers;

use App\Library\Lock;
use App\Library\Requests\Withdraw\WithdrawApplyRequest;
use App\Library\Requests\Withdraw\WithdrawPageRequest;
use App\Library\Service\WithdrawService;
use Illuminate\Http\JsonResponse;

class WithdrawController extends BaseController
{
    /**
     * @param WithdrawService $service
     */
    public function __construct(WithdrawService $service)
    {
        $this->service = $service;
    }

    /**
     * 分页
     * @param WithdrawPageRequest $request
     * @return JsonResponse
     *
     */
    public function paging(WithdrawPageRequest $request): JsonResponse
    {
        return $this->service->paging($request);
    }

    /**
     * 统计
     * @return JsonResponse
     *
     */
    public function tj(): JsonResponse
    {
        return $this->service->tj();
    }

    /**
     * 提现申请
     * @param WithdrawApplyRequest $request
     * @return mixed
     *
     */
    public function apply(WithdrawApplyRequest $request): JsonResponse
    {
        return Lock::get(USERID . 'withdrawApply', function () use ($request) {
            return $this->service->apply($request);
        });
    }
}
